<?=$this->header(true)?>


    <?=$this->menu("galleries")?>


    <h1><?=$this->message("nav.galleries")?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("nav.galleries"),
                "href"=>"gallery/list"
            ),
            array(
                "name"=>$this->message("label.images.for", _Gallery::BUNDLE) . " \"" . $this->truncateNicely($this->imageForm->getGalleryImage()->getGallery()->getName(), 10, 14, "...") . "\"",
                "href"=>"gallery/image/list"
            ),
            array(
                "name"=>($this->imageForm->getGalleryImage()->getGalleryImageId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->imageForm->getGalleryImage()->getImageRelatedByImageId()->getBinaryFile()->getFileName()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item.image", _Gallery::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Gallery::BUNDLE)?>

    <form id="<?=get_class($this->imageForm)?>" action="gallery/image/save" method="post" enctype="multipart/form-data">

        <fieldset>

            <legend><?=$this->message("label.1", _Gallery::BUNDLE)?></legend>

            <div>
                <input type="hidden"
                       name="galleryImage->galleryImageId"
                       value="<?=$this->imageForm->getGalleryImage()->getGalleryImageId()?>" />
                <input type="hidden"
                       name="galleryImage->galleryId"
                       value="<?=$this->imageForm->getGalleryImage()->getGalleryId()?>" />
                <input type="hidden"
                       name="galleryImage->imageRelatedByImageId->imageId"
                       value="<?=$this->imageForm->getGalleryImage()->getImageId()?>" />
                <input type="hidden"
                       name="galleryImage->imageRelatedByImageId->binaryFileId"
                       value="<?=$this->imageForm->getGalleryImage()->getImageRelatedByImageId()->getBinaryFileId()?>" />
                <input type="hidden"
                       name="galleryImage->imageRelatedByThumbnailId->imageId"
                       value="<?=$this->imageForm->getGalleryImage()->getThumbnailId()?>" />
                <input type="hidden"
                       name="galleryImage->imageRelatedByThumbnailId->binaryFileId"
                       value="<?=$this->imageForm->getGalleryImage()->getImageRelatedByThumbnailId()->getBinaryFileId()?>" />
            </div>

            <? if($this->imageForm->getGalleryImage()->getGalleryImageId() == 0): ?>

                <fieldset>

                    <legend style="padding-left:40px"><?=$this->message("label.required")?></legend>

                    <table cellspacing="0" cellpadding="0" class="form">
                    <tr class="ctrl<?=$this->error("formFile")?>">
                        <th><label for="formFile"><?=$this->message("prompt.image", _Gallery::BUNDLE)?></label></th>
                        <th class="required"><em>*</em></th>
                        <td>
                            <input name="formFile"
                                   id="formFile"
                                   value=""
                                   type="file"
                                   class="textInput" />
                        </td>
                    </tr>
                    </table>

                </fieldset>

            <? endif; ?>

            <fieldset>

                <legend style="padding-left:40px"><?=$this->message("label.optional")?></legend>

                <table cellspacing="0" cellpadding="0" class="form">

                <? if($this->imageForm->getGalleryImage()->getGalleryImageId() > 0): ?>
                    <tr class="ctrl<?=$this->error("formFile")?>">
                        <th><label for="formFile"><?=$this->message("prompt.image", _Gallery::BUNDLE)?></label></th>
                        <th class="required"><em>*</em></th>
                        <td>
                            <input name="formFile"
                                   id="formFile"
                                   value=""
                                   type="file"
                                   class="textInput" />
                        </td>
                    </tr>
                <? endif; ?>

                <tr class="ctrl<?=$this->error("galleryImage->caption")?>">
                    <th><label for="galleryImage_caption"><?=$this->message("prompt.caption", _Gallery::BUNDLE)?></label></th>
                    <th class="required"><em>&nbsp;</em></th>
                    <td>
                        <input name="galleryImage->caption"
                               id="galleryImage_caption"
                               value="<?=$this->imageForm->getGalleryImage()->getCaption()?>"
                               maxlength="255"
                               type="text"
                               class="textInput" />
                    </td>
                </tr>
                </table>

            </fieldset>

        </fieldset>

        <fieldset>

            <legend><?=$this->message("label.2", _Gallery::BUNDLE)?></legend>

            <fieldset>

                <legend style="padding-left:40px"><?=$this->message("label.required")?></legend>

                <table cellspacing="0" cellpadding="0" class="form">
                <tr class="ctrl<?=$this->error("path")?>">
                    <th><label for="path"><?=$this->message("prompt.directory", _Gallery::BUNDLE)?></label></th>
                    <th class="required"><em>*</em></th>
                    <td>
                        <input name="path"
                               id="path"
                               value="<?=$this->imageForm->getPath()?>"
                               maxlength="255"
                               type="text"
                               class="textInput" />
                        <p class="hint"><?=$this->message("note.directory", _Gallery::BUNDLE)?></p>
                    </td>
                </tr>
                </table>

            </fieldset>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('gallery/list')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>